import { useState, useEffect, useContext } from 'react'
import axiosContext from '@/hooks/axiosContext'
import useFetch from '@/hooks/useFetch'

const useLoadData = (url) => {
    const [data, setData] = useState([])
    const axios = useContext(axiosContext)
    const http = useFetch(axios)

    useEffect(() => {
        http.current.get({
            url
        })
        .then(result => {
            setData(result.data)
        })
    }, [http, url])

    return data
}

export default useLoadData